home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / commands / patch / common.h next >
C/C++ Source or Header  |  1990-07-23  |  4KB  |  159 lines

  1. /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
  2.  *
  3.  * $Log:    common.h,v $
  4.  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  5.  * patch12: sprintf was declared wrong
  6.  * 
  7.  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
  8.  * patch10: support for shorter extensions.
  9.  * 
  10.  * Revision 2.0  86/09/17  15:36:39  lwall
  11.  * Baseline for netwide release.
  12.  * 
  13.  */
  14.  
  15. #define DEBUGGING
  16.  
  17. #include "config.h"
  18.  
  19. /* shut lint up about the following when return value ignored */
  20.  
  21. #define Signal (void)signal
  22. #define Unlink (void)unlink
  23. #define Lseek (void)lseek
  24. #define Fseek (void)fseek
  25. #define Fstat (void)fstat
  26. #define Pclose (void)pclose
  27. #define Close (void)close
  28. #define Fclose (void)fclose
  29. #define Fflush (void)fflush
  30. #define Sprintf (void)sprintf
  31. #define Mktemp (void)mktemp
  32. #define Strcpy (void)strcpy
  33. #define Strcat (void)strcat
  34.  
  35. #include <sys/types.h>
  36. #include <sys/stat.h>
  37. #include <assert.h>
  38. #include <ctype.h>
  39. #include <signal.h>
  40. #include <stdio.h>
  41.  
  42. /* constants */
  43.  
  44. #define TRUE (1)
  45. #define FALSE (0)
  46.  
  47. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  48. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  49. #define MAXLINELEN 1024
  50. #define BUFFERSIZE 1024
  51. #define SCCSPREFIX "s."
  52. #define GET "get -e %s"
  53. #define RCSSUFFIX ",v"
  54. #define CHECKOUT "co -l %s"
  55.  
  56. #ifdef FLEXFILENAMES
  57. #define ORIGEXT ".orig"
  58. #define REJEXT ".rej"
  59. #else
  60. #define ORIGEXT "~"
  61. #define REJEXT "#"
  62. #endif
  63.  
  64. /* handy definitions */
  65.  
  66. #define Null(t) ((t)0)
  67. #define Nullch Null(char *)
  68. #define Nullfp Null(FILE *)
  69. #define Nulline Null(LINENUM)
  70.  
  71. #define Ctl(ch) ((ch) & 037)
  72.  
  73. #define strNE(s1,s2) (strcmp(s1, s2))
  74. #define strEQ(s1,s2) (!strcmp(s1, s2))
  75. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  76. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  77.  
  78. /* typedefs */
  79.  
  80. typedef char bool;
  81. typedef long LINENUM;            /* must be signed */
  82. typedef unsigned MEM;            /* what to feed malloc */
  83.  
  84. /* globals */
  85.  
  86. EXT int Argc;                /* guess */
  87. EXT char **Argv;
  88. EXT int Argc_last;            /* for restarting plan_b */
  89. EXT char **Argv_last;
  90.  
  91. EXT struct stat filestat;        /* file statistics area */
  92. EXT int filemode INIT(0644);
  93.  
  94. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  95. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  96. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  97.  
  98. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  99. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  100.  
  101. #define MAXFILEC 2
  102. EXT int filec INIT(0);            /* how many file arguments? */
  103. EXT char *filearg[MAXFILEC];
  104. EXT bool ok_to_create_file INIT(FALSE);
  105. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  106.  
  107. EXT char *outname INIT(Nullch);
  108. EXT char rejname[128];
  109.  
  110. EXT char *origext INIT(Nullch);
  111. EXT char *origprae INIT(Nullch);
  112.  
  113. EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
  114. EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");    /* might want /usr/tmp here */
  115. EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  116. EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
  117. EXT bool toutkeep INIT(FALSE);
  118. EXT bool trejkeep INIT(FALSE);
  119.  
  120. EXT LINENUM last_offset INIT(0);
  121. #ifdef DEBUGGING
  122. EXT int debug INIT(0);
  123. #endif
  124. EXT LINENUM maxfuzz INIT(2);
  125. EXT bool force INIT(FALSE);
  126. EXT bool verbose INIT(TRUE);
  127. EXT bool reverse INIT(FALSE);
  128. EXT bool noreverse INIT(FALSE);
  129. EXT bool skip_rest_of_patch INIT(FALSE);
  130. EXT int strippath INIT(957);
  131. EXT bool canonicalize INIT(FALSE);
  132.  
  133. #define CONTEXT_DIFF 1
  134. #define NORMAL_DIFF 2
  135. #define ED_DIFF 3
  136. #define NEW_CONTEXT_DIFF 4
  137. EXT int diff_type INIT(0);
  138.  
  139. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  140. EXT char if_defined[128];        /* #ifdef xyzzy */
  141. EXT char not_defined[128];        /* #ifndef xyzzy */
  142. EXT char else_defined[] INIT("#else\n");/* #else */
  143. EXT char end_defined[128];        /* #endif xyzzy */
  144.  
  145. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  146.  
  147. char *malloc();
  148. char *realloc();
  149. char *strcpy();
  150. char *strcat();
  151. long atol();
  152. long lseek();
  153. char *mktemp();
  154. #ifdef CHARSPRINTF
  155. char *sprintf();
  156. #else
  157. int sprintf();
  158. #endif
  159.